package br.com.manutencaocarro.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import br.com.manutencaocarro.R;
import br.com.manutencaocarro.adapter.ImageAdapter;

public class MainActivity extends ActionBarActivity 
{
	GridView gridView;

	static final String[] SERVICOS = new String[] { "cadastroCarro", "cadastroOficina","cadastroPeca", "relatorio" };

	@Override
	public void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		gridView = (GridView) findViewById(R.id.gridView1);

		gridView.setAdapter(new ImageAdapter(this, SERVICOS));

		gridView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) 
			{
				Intent irParaFormulario;

				switch (position) {
				case 0:
					irParaFormulario = new Intent(MainActivity.this, ListagemCarrosActivity.class);

					startActivity(irParaFormulario);

					break;

				case 1:
					irParaFormulario = new Intent( MainActivity.this, ListagemLojasActivity.class);

					startActivity(irParaFormulario);

					break;
					
				case 2:
					irParaFormulario = new Intent( MainActivity.this, ListagemPecasActivity.class );

					startActivity(irParaFormulario);
					
					break;
					
				case 3:
					irParaFormulario = new Intent( MainActivity.this, RelatorioActivity.class );

					startActivity(irParaFormulario);
					break;

				default:
					break;
				}
			}
		});
	}
}